/* * To change this template, choose Tools | Templates * and open the template in the editor. */package br.com.aspas.beans;import javax.naming.Context;import javax.naming.InitialContext;import javax.persistence.EntityManagerFactory;import javax.persistence.Persistence;import javax.transaction.UserTransaction;/** * * @author Reinaldo Viana */public class ConnectionBean {    /** Creates a new instance of ConnectionBean */    private EntityManagerFactory emf;    public ConnectionBean() {    }    public EntityManagerFactory getEntityManagerFactory() {        if (emf == null) {            emf = Persistence.createEntityManagerFactory("AspasPU", new java.util.HashMap());        }        return emf;    }    public UserTransaction getUserTransaction() throws Exception {        Context ctx = new InitialContext();        UserTransaction utx = (UserTransaction) ctx.lookup("UserTransaction");        return utx;    }}